/****************************************************************************
 *
 *  SMARTALL.H
 *
 *  (C) Copyright 1997 by Autodesk, Inc.
 *
 *  This program is copyrighted by Autodesk, Inc. and is licensed to you under
 *  the following conditions.  You may not distribute or publish the source
 *  code of this program in any form.  You may incorporate this code in object
 *  form in derivative works provided such derivative works are (i.) are de-
 *  signed and intended to work solely with Autodesk, Inc. products, and (ii.)
 *  contain Autodesk's copyright notice "(C) Copyright 1995 by Autodesk, Inc."
 *
 *  AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.  AUTODESK SPE-
 *  CIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
 *  A PARTICULAR USE.  AUTODESK, INC.  DOES NOT WARRANT THAT THE OPERATION OF
 *  THE PROGRAM WILL BE UNINTERRUPTED OR ERROR FREE.
 *
 ***************************************************************************/

#ifndef SMARTALL_H
#define SMARTALL_H
/*

	Definitions for the smart memory allocator

*/

#ifdef SMARTALLOC

typedef enum {False = 0, True = 1} Boolean;
typedef unsigned short ushort;

void sm_free(void *fp);
void *sm_malloc(const char *fname, int lineno, unsigned long nbytes);
void *sm_calloc(const char *fname, int lineno, unsigned long nelem, unsigned long elsize);
void *sm_realloc(const char *fname, int lineno, void *ptr, unsigned long size);
void *actuallymalloc(unsigned long size);
void *actuallycalloc(unsigned long nelem, unsigned long elsize);
void *actuallyrealloc(void *ptr, unsigned long size);
void actuallyfree(void *cp);
void sm_tag(char *tag);
void sm_untag();
void sm_dump(Boolean bufdump);
void sm_static(int mode);


/* Redefine standard memory allocator calls to use our routines
   instead. */

#define free	       sm_free
#define cfree	       sm_free
#define malloc(x)      sm_malloc(__FILE__, __LINE__, (x))
#define calloc(n,e)    sm_calloc(__FILE__, __LINE__, (n), (e))
#define realloc(p,x)   sm_realloc(__FILE__, __LINE__, (p), (x))

#else

/* extern void *malloc(), *calloc(), *realloc();
extern void free();
*/

/* If SMARTALLOC is disabled, define its special calls to default to
   the standard routines.  */

#define actuallyfree(x)      free(x)
#define actuallymalloc(x)    malloc(x)
#define actuallycalloc(x,y)  calloc(x,y)
#define actuallyrealloc(x,y) realloc(x,y)
#define sm_dump(x)
#define sm_static(x)
#define sm_tag(x)
#define sm_untag()
#endif

#endif /* SMARTALL_H */
